public class MobileAppTracker extends Object
Modifier and Type | Field and Description |
---|---|
protected MATEventQueue |
eventQueue |
protected boolean |
initialized |
protected boolean |
isRegistered |
protected Context |
mContext |
protected BroadcastReceiver |
networkStateReceiver |
protected MATParameters |
params |
protected ExecutorService |
pubQueue |
protected MATTestRequest |
tuneRequest |
Modifier | Constructor and Description |
---|---|
protected |
MobileAppTracker() |
Modifier and Type | Method and Description |
---|---|
protected void |
addEventToQueue(String link,
String data,
JSONObject postBody,
boolean firstSession) |
void |
checkForDeferredDeeplink(MATDeeplinkListener listener)
Checks for a deferred deeplink if exists
Opens deferred deeplink if found and returns value in MATDplinkListener
|
protected void |
dumpQueue() |
String |
getAction()
Gets the action of the event
|
String |
getAdvertiserId()
Gets the TUNE advertiser ID.
|
int |
getAge()
Gets the user age set.
|
double |
getAltitude()
Gets the device altitude.
|
String |
getAndroidId()
Gets the ANDROID_ID of the device
|
boolean |
getAppAdTrackingEnabled()
Get whether the user has app-level ad tracking enabled or not.
|
String |
getAppName()
Gets the app name
|
int |
getAppVersion()
Gets the app version
|
String |
getConnectionType()
Gets the connection type (mobile or WIFI);.
|
String |
getCountryCode()
Gets the ISO 639-1 country code
|
String |
getCurrencyCode()
Gets the ISO 4217 currency code.
|
String |
getDeviceBrand()
Gets the device brand/manufacturer (HTC, Apple, etc)
|
String |
getDeviceCarrier()
Gets the device carrier if any
|
String |
getDeviceId()
Gets the Device ID, also known as IMEI/MEID, if any
|
String |
getDeviceModel()
Gets the device model name
|
boolean |
getExistingUser()
Gets value previously set of existing user or not.
|
String |
getFacebookUserId()
Gets the Facebook user ID previously set.
|
int |
getGender()
Gets the user gender set.
|
boolean |
getGoogleAdTrackingLimited()
Gets whether use of the Google Play Services Advertising ID is limited by user request.
|
String |
getGoogleAdvertisingId()
Gets the Google Play Services Advertising ID.
|
String |
getGoogleUserId()
Gets the Google user ID previously set.
|
long |
getInstallDate()
Gets the date of app install
|
String |
getInstallReferrer()
Gets the Google Play INSTALL_REFERRER
|
static MobileAppTracker |
getInstance()
Get existing TUNE singleton object
|
boolean |
getIsPayingUser()
Gets whether the user is revenue-generating or not
|
String |
getLanguage()
Gets the language of the device
|
String |
getLastOpenLogId()
Gets the last TUNE open log ID
|
double |
getLatitude()
Gets the device latitude.
|
double |
getLongitude()
Gets the device longitude.
|
String |
getMacAddress()
Gets the MAC address of device
|
String |
getMatId()
Gets the MAT ID generated on install
|
String |
getMCC()
Gets the mobile country code.
|
String |
getMNC()
Gets the mobile network code.
|
String |
getOpenLogId()
Gets the first TUNE open log ID
|
String |
getOsVersion()
Gets the Android OS version
|
String |
getPackageName()
Gets the app package name
|
String |
getPluginName()
Get SDK plugin name used
|
String |
getReferralSource()
Gets the package name of the app that started this Activity, if any
|
String |
getReferralUrl()
Gets the url scheme that started this Activity, if any
|
String |
getRefId()
Gets the advertiser ref ID.
|
Double |
getRevenue()
Gets the revenue amount set
|
String |
getScreenDensity()
Gets the screen density of the device
|
String |
getScreenHeight()
Gets the screen height of the device in pixels
|
String |
getScreenWidth()
Gets the screen width of the device in pixels
|
String |
getSDKVersion()
Gets the TUNE SDK version
|
String |
getSiteId()
Gets the TUNE site ID set
|
String |
getTRUSTeId()
Gets the TRUSTe ID set
|
String |
getTwitterUserId()
Gets the Twitter user ID previously set.
|
String |
getUserAgent()
Gets the device browser user agent
|
String |
getUserEmail()
Gets the custom user email.
|
String |
getUserId()
Gets the custom user ID.
|
String |
getUserName()
Gets the custom user name.
|
static MobileAppTracker |
init(Context context,
String advertiserId,
String conversionKey)
Initializes the TUNE SDK.
|
protected void |
initAll(String advertiserId,
String conversionKey)
Private initialization function for TUNE SDK.
|
static boolean |
isOnline(Context context)
Returns true if an Internet connection is detected.
|
protected boolean |
makeRequest(String link,
String data,
JSONObject postBody)
Helper function for making single request and displaying response
|
void |
measureEvent(int eventId)
Event measurement function that measures an event for the given eventId.
|
void |
measureEvent(MATEvent eventData)
Event measurement function that measures an event based on TuneEvent values.
|
void |
measureEvent(String eventName)
Event measurement function that measures an event for the given eventName.
|
void |
measureSession()
Main session measurement function; this function should be called in onResume().
|
void |
setAdvertiserId(String advertiserId)
Sets the TUNE advertiser ID
|
void |
setAge(int age)
Sets the user's age.
|
void |
setAllowDuplicates(boolean allow)
Enables acceptance of duplicate installs from this device.
|
void |
setAltitude(double altitude)
Sets the device altitude.
|
void |
setAndroidId(String androidId)
Sets the ANDROID ID
|
void |
setAndroidIdMd5(String androidIdMd5)
Sets the ANDROID ID MD5 hash
|
void |
setAndroidIdSha1(String androidIdSha1)
Sets the ANDROID ID SHA-1 hash
|
void |
setAndroidIdSha256(String androidIdSha256)
Sets the ANDROID ID SHA-256 hash
|
void |
setAppAdTrackingEnabled(boolean adTrackingEnabled)
Sets whether app-level ad tracking is enabled.
|
void |
setConversionKey(String conversionKey)
Sets the conversion key for the SDK
|
void |
setCurrencyCode(String currency_code)
Sets the ISO 4217 currency code.
|
void |
setDebugMode(boolean debug)
Turns debug mode on or off, under tag "MobileAppTracker".
|
void |
setDeeplinkListener(MATDeeplinkListener listener) |
void |
setDeviceBrand(String deviceBrand)
Sets the device brand, or manufacturer
|
void |
setDeviceId(String deviceId)
Sets the device IMEI/MEID
|
void |
setDeviceModel(String deviceModel)
Sets the device model
|
void |
setEmailCollection(boolean collectEmail)
Enables or disables primary Gmail address collection
Requires GET_ACCOUNTS permission
|
void |
setExistingUser(boolean existing)
Sets whether app was previously installed prior to version with MAT SDK
|
void |
setFacebookEventLogging(boolean logging,
Context context,
boolean limitEventAndDataUsage)
Whether to log TUNE events in the FB SDK as well
|
void |
setFacebookUserId(String fb_user_id)
Sets the user ID to associate with Facebook
|
void |
setGender(MATGender gender)
Sets the user gender.
|
void |
setGoogleAdvertisingId(String adId,
boolean isLATEnabled)
Sets the Google Play Services Advertising ID
|
void |
setGoogleUserId(String google_user_id)
Sets the user ID to associate with Google
|
void |
setInstallReferrer(String referrer)
Overrides the Google Play INSTALL_REFERRER received
|
void |
setIsPayingUser(boolean isPayingUser)
Sets whether the user is revenue-generating or not
|
void |
setLatitude(double latitude)
Sets the device latitude.
|
void |
setLocation(Location location) |
void |
setLongitude(double longitude)
Sets the device longitude.
|
void |
setMacAddress(String macAddress)
Sets the device MAC address.
|
void |
setMATResponse(MATResponse listener)
Register a MATResponse interface to receive server response callback
|
void |
setOsVersion(String osVersion)
Sets the device OS version
|
void |
setPackageName(String packageName)
Sets the app package name
|
void |
setPhoneNumber(String phoneNumber)
Sets the device phone number
|
void |
setPluginName(String plugin_name)
Set the name of plugin used, if any
|
void |
setPreloadedApp(MATPreloadData preloadData)
Sets publisher information for device preloaded apps
|
void |
setReferralSources(Activity act)
Get referral sources from Activity
|
void |
setSiteId(String siteId)
Sets the TUNE site ID to specify which app to attribute to
|
void |
setTRUSTeId(String tpid)
Sets the TRUSTe ID, should generate via their SDK
|
void |
setTwitterUserId(String twitter_user_id)
Sets the user ID to associate with Twitter
|
void |
setUserEmail(String userEmail)
Sets the custom user email.
|
void |
setUserId(String userId)
Sets the custom user ID.
|
void |
setUserName(String userName)
Sets the custom user name.
|
protected BroadcastReceiver networkStateReceiver
protected Context mContext
protected ExecutorService pubQueue
protected MATEventQueue eventQueue
protected MATParameters params
protected MATTestRequest tuneRequest
protected boolean initialized
protected boolean isRegistered
public static MobileAppTracker getInstance()
public static MobileAppTracker init(Context context, String advertiserId, String conversionKey)
context
- the application contextadvertiserId
- the TUNE advertiser ID for the appconversionKey
- the TUNE advertiser key for the appprotected void initAll(String advertiserId, String conversionKey)
advertiserId
- the TUNE advertiser ID for the appconversionKey
- the TUNE conversion key for the apppublic static boolean isOnline(Context context)
context
- the app context to check connectivity fromprotected void addEventToQueue(String link, String data, JSONObject postBody, boolean firstSession)
protected void dumpQueue()
public void measureSession()
public void measureEvent(String eventName)
eventName
- event name in TUNE systempublic void measureEvent(int eventId)
eventId
- event ID in TUNE systempublic void measureEvent(MATEvent eventData)
new TuneEvent(eventName)
eventData
- custom data to associate with the eventprotected boolean makeRequest(String link, String data, JSONObject postBody)
public String getAction()
public String getAdvertiserId()
public int getAge()
public double getAltitude()
public String getAndroidId()
public boolean getAppAdTrackingEnabled()
public String getAppName()
public int getAppVersion()
public String getConnectionType()
public String getCountryCode()
public String getCurrencyCode()
public String getDeviceBrand()
public String getDeviceCarrier()
public String getDeviceId()
public String getDeviceModel()
public boolean getExistingUser()
public String getFacebookUserId()
public int getGender()
public String getGoogleAdvertisingId()
public boolean getGoogleAdTrackingLimited()
public String getGoogleUserId()
public long getInstallDate()
public String getInstallReferrer()
public boolean getIsPayingUser()
public String getLanguage()
public String getLastOpenLogId()
public double getLatitude()
public double getLongitude()
public String getMacAddress()
public String getMatId()
public String getMCC()
public String getMNC()
public String getOpenLogId()
public String getOsVersion()
public String getPackageName()
public String getPluginName()
public String getReferralSource()
public String getReferralUrl()
public String getRefId()
public Double getRevenue()
public String getScreenDensity()
public String getScreenHeight()
public String getScreenWidth()
public String getSDKVersion()
public String getSiteId()
public String getTRUSTeId()
public String getTwitterUserId()
public String getUserAgent()
public String getUserEmail()
public String getUserId()
public String getUserName()
public void setAdvertiserId(String advertiserId)
advertiserId
- TUNE advertiser IDpublic void setAge(int age)
age
- User age to track in MATpublic void setAltitude(double altitude)
altitude
- device altitudepublic void setAndroidId(String androidId)
androidId
- ANDROID_IDpublic void setAndroidIdMd5(String androidIdMd5)
androidIdMd5
- ANDROID_ID MD5 hashpublic void setAndroidIdSha1(String androidIdSha1)
androidIdSha1
- ANDROID_ID SHA-1 hashpublic void setAndroidIdSha256(String androidIdSha256)
androidIdSha256
- ANDROID_ID SHA-256 hashpublic void setAppAdTrackingEnabled(boolean adTrackingEnabled)
adTrackingEnabled
- true if user has opted out of ad tracking at the app-level, false if notpublic void setConversionKey(String conversionKey)
conversionKey
- TUNE conversion keypublic void setCurrencyCode(String currency_code)
currency_code
- the currency codepublic void setDeeplinkListener(MATDeeplinkListener listener)
public void setDeviceBrand(String deviceBrand)
deviceBrand
- device brandpublic void setDeviceId(String deviceId)
deviceId
- device IMEI/MEIDpublic void setDeviceModel(String deviceModel)
deviceModel
- device modelpublic void setExistingUser(boolean existing)
existing
- true if this user already had the app installed prior to updating to MAT versionpublic void setFacebookUserId(String fb_user_id)
fb_user_id
- public void setGender(MATGender gender)
gender
- use MATGender.MALE, MATGender.FEMALEpublic void setGoogleAdvertisingId(String adId, boolean isLATEnabled)
adId
- Google Play advertising IDisLATEnabled
- whether user has requested to limit use of the Google ad IDpublic void setGoogleUserId(String google_user_id)
google_user_id
- public void setInstallReferrer(String referrer)
referrer
- Your custom referrer valuepublic void setIsPayingUser(boolean isPayingUser)
isPayingUser
- true if the user has produced revenue, false if notpublic void setLatitude(double latitude)
latitude
- the device latitudepublic void setLocation(Location location)
public void setLongitude(double longitude)
longitude
- the device longitudepublic void setMacAddress(String macAddress)
macAddress
- device MAC addresspublic void setMATResponse(MATResponse listener)
listener
- a MATResponse object that will be called when server request is completepublic void setOsVersion(String osVersion)
osVersion
- device OS versionpublic void setPackageName(String packageName)
packageName
- App package namepublic void setPhoneNumber(String phoneNumber)
phoneNumber
- Phone numberpublic void setPreloadedApp(MATPreloadData preloadData)
preloadData
- Preload app attribution datapublic void setReferralSources(Activity act)
act
- Activity to get referring package name and url scheme frompublic void setSiteId(String siteId)
siteId
- TUNE site ID to attribute topublic void setTRUSTeId(String tpid)
tpid
- TRUSTe IDpublic void setTwitterUserId(String twitter_user_id)
twitter_user_id
- public void setUserEmail(String userEmail)
userEmail
- the user emailpublic void setUserId(String userId)
userId
- the user idpublic void setUserName(String userName)
userName
- the usernamepublic void setPluginName(String plugin_name)
plugin_name
- public void setAllowDuplicates(boolean allow)
allow
- whether to allow duplicate installs from devicepublic void setDebugMode(boolean debug)
debug
- whether to enable debug outputpublic void setEmailCollection(boolean collectEmail)
collectEmail
- whether to collect device email addresspublic void setFacebookEventLogging(boolean logging, Context context, boolean limitEventAndDataUsage)
logging
- Whether to send TUNE events to FB as wellcontext
- Activity contextlimitEventAndDataUsage
- Whether user opted out of ads targetingpublic void checkForDeferredDeeplink(MATDeeplinkListener listener)
listener
- listener for deeplink value or error